package com.un10.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


import com.un10.entity.Rotationchart;
import com.un10.service.RotaService;
import com.un10.util.Result;

@Controller
public class RotationchartController {
@Autowired
	RotaService rotService;
//查询
@RequestMapping("/houtai/getRot")
@ResponseBody
public Object getRot(@RequestParam ("page")int page,@RequestParam ("limit")int limit,@RequestParam("rotName")String rotName) {
	
	List<Rotationchart>  rotationchart=rotService.findAllRot((page-1)*limit, limit,rotName);
	int count=rotService.getCount();
	if(rotName!=null ) {
		rotName=null;
	}
	System.out.println(rotationchart);
	com.un10.util.Result res=new com.un10.util.Result(0, "", count, rotationchart);
    return  res ;
}
 @RequestMapping("/RotationchartControllerIndex")
	public String RotationchartControllerIndex() {
		System.out.println(456);
		return "Rotationchart";
	}
	//添加
 @RequestMapping("/houtai/Rotadd")
 @ResponseBody
 public Object Rotadd(@RequestParam Map<String, Object> map) {	
	int i = rotService.findRotAdd(map);
	Result res = new Result(0, "", i, true);
	return res;
}
 
 @RequestMapping("/houtai/Rotupdate")
	@ResponseBody
	public Object Rotupdate(@RequestParam Map<String, Object> map) {
	
		int i = rotService.findRotUpdate(map);
		Result res = new Result(0, "", i, true);
		return res;
	}
 @RequestMapping("/houtai/deleteRotation")
	@ResponseBody
	public Object deleteRotation(@RequestParam("rotID") Integer rotID) {
		int i = rotService.findRotDelete(rotID);
		Result res = new Result(0, "", i, true);
		return res;
	}
 
}
